package yzy.ecps.dao.impl;

import java.util.List;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import yzy.ecps.dao.GoodsDao;
import yzy.ecps.model.BtcGoods;
import yzy.ecps.query.condition.GoodsQueryCondition;
import yzy.ecps.query.condition.PortalGoodsCondition;

@Repository
public class GoodsDaoImpl extends SqlSessionDaoSupport implements GoodsDao {
	
	String ns = "btc_goods.";
	
	public List<BtcGoods> findByCondition(GoodsQueryCondition gqc) {
		return getSqlSession().selectList(ns+"findByCondition", gqc);
	}

	public int getCountByCondition(GoodsQueryCondition gqc) {
		return getSqlSession().selectOne(ns+"getCountByCondition", gqc);
	}

	public void saveGoods(BtcGoods goods) {
		getSqlSession().insert(ns+"insert", goods);
	}

	public void updateGoods(BtcGoods goods) {
		getSqlSession().update(ns+"updateByPrimaryKeySelective", goods);
	}

	public List<BtcGoods> findByPortalCondition(PortalGoodsCondition pgc) {
		return getSqlSession().selectList(ns+"findByPortalGoodsCondition", pgc);
	}

	public int getCountByPortalCondition(PortalGoodsCondition pgc) {
		return getSqlSession().selectOne(ns+"findCountByPortalGoodsCondition", pgc);
	}

	public BtcGoods getGoodsById(Long goodsId) {
		return getSqlSession().selectOne(ns+"findGoodsById", goodsId);
	}

}
